<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>SM3算法文本加密</title>
</head>

<body>
    <div style="text-align:center;">
        <form name="form1">
            <p>
                <br /> <br />
            <div>
                加密文本: <input type="text" id="sm3word" name="sm3word" value="" size="80" />
                <input type="button" value="加密" onClick="doSM3();" /><br /><br /><br /><br />
            </div>
            <div>
                加密结果: <input type="text" id="sm3key" value="" size="100" /><br /><br /><br />
            </div>
            <div>
                计算时间: <input type="text" id="time" value="" size="100" /><br /><br /><br />
            </div>
            
            </p>
        </form>
    </div>

    <script src="js/sm3.js"></script>
    <script src="js/long.js"></script>
    <script>
        function doSM3() {
            const word = document.getElementById("sm3word").value
            var bytes = new Uint8Array(word);
            let time = new Date().getTime();
            var sm3Hash = sm3Sum(bytes)
            var sm3HashHex = encodeByteToString(sm3Hash, 0, sm3Hash.length);//编码成16进制可见字符
            document.getElementById("sm3key").value = sm3HashHex
            document.getElementById("time").value = ((new Date().getTime() - time) / 1000)+" s"
        }
    </script>
</body>

</html>